package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqSupplier;
import com.drug.mingkang.mapper.HqSupplierMapper;
import com.drug.mingkang.service.HqSupplierService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 供应商(HqSupplier)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:13
 */
@Service("hqSupplierService")
public class HqSupplierServiceImpl implements HqSupplierService {
    @Resource
    private HqSupplierMapper hqSupplierMapper;

    @Override
    public int updates(HqSupplier hqSupplier) {

        return  this.hqSupplierMapper.updates(hqSupplier);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param supId 主键
     * @return 实例对象
     */
    @Override
    public HqSupplier queryById(String supId) {
        return this.hqSupplierMapper.queryById(supId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqSupplier> queryAllByLimit(int offset, int limit,String supName,String supPhone) {
        return this.hqSupplierMapper.queryAllByLimit((offset-1)*limit, limit,supName,supPhone);
    }

    /**
     * 新增数据
     *
     * @param hqSupplier 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(HqSupplier hqSupplier) {

        return this.hqSupplierMapper.insert(hqSupplier);
    }

    /**
     * 修改数据
     *
     * @param supId 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(String[] supId) {
        return this.hqSupplierMapper.update(supId) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param supId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String supId) {
        return this.hqSupplierMapper.deleteById(supId) > 0;
    }

    @Override
    public int selectCount(String supName) {
        return this.hqSupplierMapper.selectCount(supName);
    }
}